import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, CreateDateColumn } from 'typeorm';
import { Project } from './project.entity';
import { User } from '../user/user.entity';

@Entity()
export class ProjectShare {
  @PrimaryGeneratedColumn()
  id: number;

  @ManyToOne(() => Project, { onDelete: 'CASCADE' })
  project: Project;

  @ManyToOne(() => User, { onDelete: 'CASCADE' })
  sharedBy: User; // 分享该项目的管理员

  @Column({ type: 'text', nullable: true })
  qrCodeData: string; // 该管理员分享的二维码数据

  @Column({ unique: true })
  shareToken: string; // 唯一的分享标识符，用于二维码链接

  @CreateDateColumn()
  createdAt: Date;

  @Column({ default: true })
  isActive: boolean; // 是否激活，可以用来禁用某个分享
}